#include<stdio.h>
#include<unistd.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<string.h>
#include<stdlib.h>


int main()
{
        int sd,port,ssd,ch,j=0;
        char msg[80],buf[255];
	FILE *fp;
        struct sockaddr_in cli;
        sd=socket(AF_INET,SOCK_STREAM,0);
        bzero(&cli,sizeof(cli));
        printf("enter the port no");
        scanf("%d",&port);
        cli.sin_port=port;
        cli.sin_addr.s_addr=INADDR_ANY;
        cli.sin_family=AF_INET;
	bind(sd,(struct sockaddr*)&cli,sizeof(cli));
	listen(sd,1);
	int i=sizeof(cli);
	ssd=accept(sd,(struct sockaddr*)&cli,&i);
	memset(msg,'\0',sizeof(msg));
	//read(ssd,msg,10);
	//system(msg);
	//printf("\nenter your msg to client\n");
	//scanf("%s",msg);
	//write(ssd,msg,strlen(msg));	
	fp=fopen("in.txt","a+");
	ch=fgetc(fp);
	while(ch!=EOF)
	{
		msg[j]=ch;
		j++;
		ch=fgetc(fp);
	}
	write(ssd,msg,strlen(msg));	
	fclose(fp);
        return 0;
}

